import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Properties;
import java.util.WeakHashMap;

import javax.imageio.ImageIO;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.swing.JFrame;
import javax.swing.JLabel;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.security.crypto.codec.Base64;

import com.googlecode.charts4j.Data;
import com.googlecode.charts4j.GCharts;
import com.googlecode.charts4j.LineChart;
import com.googlecode.charts4j.Plot;
import com.googlecode.charts4j.Plots;
import com.googlecode.charts4j.Slice;

import java.security.MessageDigest;

public class Main {
    @Autowired
    private static ApplicationContext appContext;
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
//        Foo temp = new Zap();
//        temp.go();
//        HashMap<String, Employee> aMap = new 
//                HashMap<String, Employee>();
//        HashMap<String, Employee> map = new 
//                HashMap<String, Employee>();
//        WeakReference<HashMap<String, Employee>> aMap = 
//                new WeakReference<HashMap<String, Employee>>(
//                        map);
//        
//        map = null;
//
//        while (null != aMap.get()) {
//            aMap.get().put(new String("Vinoth"),
//                    new Employee("Programmer"));
//            System.out.println("Size of aMap " + aMap.get().size());
//            System.gc();
//        }
//        System.out.println("Size of aMap " + aMap.get().size());
//        System.out.println("Its garbage collected");
//     Employee emp = new Employee("Vinoth");
//     String key = "E1231231";
//    
//     aMap.put(key, emp);
//    
//     emp = null;
//    
//     System.gc();
     
     
     //System.out.println("Size of Map " + aMap.size());
     
//     int count = 0;
//     System.out.println("Took " + count
//             + " calls to System.gc() to result in weakHashMap size of : "
//             + aMap.size());
//     while (0 != aMap.size()) {
//         ++count;
//         System.gc();
//     }
//     System.out.println("Took " + count
//             + " calls to System.gc() to result in weakHashMap size of : "
//             + aMap.size());
        
        try{
            String password = "daviteq@123";
            
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(password.getBytes());
     
            byte byteData[] = md.digest();
     
            //convert the byte to hex format method 1
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < byteData.length; i++) {
             sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
            }
     
            System.out.println("Digest(in hex format):: " + sb.toString());
     
            //convert the byte to hex format method 2
            StringBuffer hexString = new StringBuffer();
            for (int i=0;i<byteData.length;i++) {
                String hex=Integer.toHexString(0xff & byteData[i]);
                if(hex.length()==1) hexString.append('0');
                hexString.append(hex);
            }
            System.out.println("Digest(in hex format):: " + hexString.toString());
        }catch(Exception e){
            
        }
        
        
    }
  

}
